<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"/>
    <link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all"/>
    <style>
        .layui-form-item .layui-input-inline {
            width: 150px;
        }
        .layui-form-label {
            padding: 9px 5px;
            width: auto;
        }
    </style>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-card">
        <form class="layui-form" id="sbumitForm">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">

                    <div class="layui-inline ">
                        <label class="layui-form-label">年度</label>
                        <div class="layui-input-inline" style="width: 150px">
                            <select name="years">
                                <option value="">全部</option>
                                <?php foreach($date as $vlaue) {?>
                                <option value="{$vlaue}">{$vlaue}年</option>
                                <?php }?>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline" style="width:80px;">
                        <div class="layui-input-inline" style="width:80px;">
                            <div class="layui-btn" id="submit">
                                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                            </div>
                        </div>
                    </div>
                    <div class="layui-inline" style="float: right">
                        <a class="layui-btn" href="javascript:;" onclick="conf()">
                            规则配置
                        </a>
                    </div>
                </div>
            </div>
        </form>

        <div class="layui-card-body layui-table-body layui-table-main">
            <table id="demo" lay-filter="demo"></table>
        </div>
    </div>
</div>

<script src="/static/jquery.min.js"></script>
<script src="/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: "/layuiadmin/", //静态资源所在路径
    }).extend({
        index: "lib/index", //主入口模块
    }).use(["table", "laydate", 'form'], function () {
        $ = layui.jquery, form = layui.form, table = layui.table, laydate = layui.laydate;

        $("#submit").click(function () {
            table.render(table_conf());
        });
        table.render(table_conf());
    });

    function table_conf() {
        return  {
            elem: '#demo',
            id: '#demo',
            url: '/admin/guess_top/index?' + $("#sbumitForm").serialize(),
            defaultToolbar: [
                'filter','print',{title:'提示',layEvent: 'LAYTABLE_EXCEL',icon: 'layui-icon-table'},
            ],
            page: {
                curr: 1   //默认从第一页开始搜索
            },
            isAloneColumn: false,
            opOrientation: 'h',
            method: "get",
            //where: $("#sbumitForm").serialize(),
            limit: 20,
            limits: [20, 30, 50, 100],
            text: {
                none: '暂无相关数据！'//默认无数据
            },
            response: {
                statusName: 'code', //数据状态的字段名称，默认：code
                statusCode: 0,//成功的状态码，默认：0
                msgName: 'msg', //状态信息的字段名称，默认：msg
                countName: 'count', //数据总数的字段名称，默认：count
                dataName: 'list', //数据列表的字段名称，默认：data
            },
            cols: [[
                {field: 'weeks_string', width: 330, title: '统计时间', align: 'center'},
                {field: 'total_people', width: 150, title: '参与人数<img src="/static/help.png" height="14px" width="auto" title="统计时间内成功参与竞猜的人数" />', align: 'center'},
                {field: 'total_degree', width: 150, title: '参与次数<img src="/static/help.png" height="14px" width="auto" title="统计时间内成功参与竞猜的次数" />', align: 'center'},
                {field: 'total_sales', width: 150, title: '总竞猜额度<img src="/static/help.png" height="14px" width="auto" title="统计时间内用户下注的额度" />', align: 'center'},
                {field: 'total_reward', width: 150, title: '总中奖额度<img src="/static/help.png" height="14px" width="auto" title="统计时间内用户赢取的额度" />', align: 'center',},
                {field: 'average_reward', width: 170, title: '平均盈利<img src="/static/help.png" height="14px" width="auto" title="统计时间内的总盈利额度/参与人数" />', align: 'center'},
                {title: '操作',align: 'center',templet: function (item) {
                        return '<a class="layui-btn layui-btn-xs" style="background-color: #1E9FFF" onclick="info(\'' + item['weeks'] + '\',\'' + item['weeks_string'] + '\')"><i class="layui-icon"></i>查看</a>';
                    }
                }
            ]],
            done: function (res, curr, count) {
                res.list.forEach(function (item, index) {

                });
            },
        };
    }

    /*详情*/
    function info(id, title) {
        layer.open({
            type: 2,
            title: [title + ' 排行统计', 'font-size:16px'],
            content: '/admin/guess_top/info?id=' + id,
            area: ['100%', '100%'],
            //offset: '0px',
        });
    }

    /*配置*/
    function conf() {
        layer.open({
            type: 2,
            title: ['配置规则', 'font-size:16px'],
            content: '/admin/guess_top/conf',
            area: ['660px', '520px'],
            //offset: '0px',
        });
    }

</script>
</body>
</html>
